//- Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd. 
//- <https://www.chatopera.com>, Licensed under the Chunsong Public 
//- License, Version 1.0  (the "License"), https://docs.cskefu.com/licenses/v1.html
//- Unless required by applicable law or agreed to in writing, software
//- distributed under the License is distributed on an "AS IS" BASIS,
//- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//- See the License for the specific language governing permissions and
//- limitations under the License.
//- Copyright (C) 2018-Jun. 2023 Chatopera Inc, <https://www.chatopera.com>
//- Licensed under the Apache License, Version 2.0
//- http://www.apache.org/licenses/LICENSE-2.0
extends /apps/include/layout.pug

block append head
    link(rel='stylesheet', href='/js/ztree/zTreeStyle/zTreeStyle.css')
    script(src='/js/ztree/jquery.ztree.all.min.js')
    script(src='/js/lodash-4.17.4.min.js')
    script(src='/js/CSKeFu_Rest_Request.v1.js')
    script.
        cususerid = '#{user.id}';
// <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
block content
    include templates/tpl.pug
    #ccaIndex(style='height: 100%')
        if !agentUserList.empty()
            .layui-side.layui-bg-black.layui-left-black.cskefu-cca-leftside(style="height:100%")
                #agentuserscca.layui-side-scroll
                    include agentusers.pug
            #ukefu-chat-agent.layui-body.ukefu-chat-agent
                //if curagentuser.channeltype == "phone"
                //    include mainagentuser_callout.pug
                //else if curagentuser.channeltype == "skype"
                //    include mainagentuser_skype.pug
                //else
                include mainagentuser.pug
        else
            .layui-layout.layui-layout-content(style='height: 100%;')
                .box.default-box(style='height: 100%;')
                    .box-body.ukefu-im-theme
                        .ukefu-empty(style='background: none')
                            i.layui-icon 
                            div 还没有任何对话
    if !agentUserList.empty()
        script(language="javascript").
            $(document).ready(function () {
                $(document).bind("keydown", "Ctrl+return", function (ev) {
                    sendMessage();
                    return false;
                })
            });
            function otherTopicSearch() {
                console.log("otherTopicSearch")
                loadURLWithTip("/agent/other/topic.html?q=" + encodeURIComponent($("#otherSearchQuery").val()), "#topiclist", null, false, true);
            }
            function otherTopicEnter() {
                if (window.event.keyCode == 13) {
                    otherTopicSearch();
                }
            }
            function cleanTopMsgTip(tip) {
                var lastMsgNum = $(tip).find('.last-msg').text();
                if (lastMsgNum) {
                    var num = Number.parseInt(lastMsgNum);
                    Proxy.cleanTopMsgTip(num)
                }
            }

